Elisp Boolean
Table of Contents
There’s no boolean type in elisp. nil, 'nil, and empty list are false, anything else is true. By convention, t is used for true.
There’re also boolean functions, and, or, not. All of them can accept any number of arguments.
1. Equality Test
We can use equal function to test both datatype and value; eq for checking if they are same object; string-equal for comparing strings
2. Functions whose Names End in p
Functions whose names that end with p means that they returns boolean. p stands for predicate. For examples,
(boundp SYMBOL)- returns true if
SYMBOL’s value is not void. (buffer-modified-p &optional BUFFER)- returns non-nil if
BUFFERwas modified since its file was last read or saved. By default,BUFFERrefers to the current buffer. IfBUFFERwas autosaved since it was last modified, it returns the symbolautosaved. (consp OBJECT)- return true if
OBJECTis a cons cell. (fboundp SYMBOL)- returns true if
SYMBOLhas function definition (featurep FEATURE &optional SUBFEATURE)- returns true if
FEATUREis present in this Emacs. (file-directory-p FILENAME)- returns true if
FILENAMEnames an existing directory;nilif it does not name a directory, or cannot determine. (file-exists-p FILENAME)- returns true if it exists, regardless of whether we can read.
(file-readable-p FILENAME)- returns true if it exists and is readable.
(functionp OBJECT),integerp, listp, ~numberp,stringp,symbolp,vectorp,zerop- returns true if
OBJECTis a function, or integer, or list, ……